home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club (Business) 1997 July / Software of the Month Club - Business (Volume 239) (July 1997).iso / pc / code / h.dxr / 00005_puzzle handlers 1.ls < prev    next >
Encoding:
Text File  |  1996-02-15  |  11.4 KB  |  347 lines

  1. global gObjects, gCursorlist, cNullCast, gObjectsH, gStates, gWorld, NULLrect, gEnvironmentSound, sQTCharSprite
  2.  
  3. on DoDefibPaddle2
  4.   DynamicLOCRECT(#DefibPaddle2)
  5. end
  6.  
  7. on DoDefibPaddle1
  8.   DynamicLOCRECT(#DefibPaddle1)
  9. end
  10.  
  11. on GrabDragDefibCable OBJref
  12.   set H to the mouseH
  13.   set V to the mouseV
  14.   set OBj to getaProp(gObjects, OBJref)
  15.   set OffsetH to H - the locH of sprite getaProp(OBj, #SpriteNum)
  16.   set OffsetV to V - the locV of sprite getaProp(OBj, #SpriteNum)
  17.   set cableref to getaProp(OBj, #CABLE)
  18.   set Anchor to getaProp(getaProp(gObjects, cableref), #Anchor)
  19.   if not voidp(getaProp(getaProp(OBj, #sound), #down)) then
  20.     playSound(getaProp(getaProp(OBj, #sound), #down), #keyframeCast, #NOW)
  21.   end if
  22.   cursor(getaProp(gCursorlist, #Grab))
  23.   set constrainRect to getConstrainRect(OBJref)
  24.   repeat while the mouseDown
  25.     set hLoc to H - OffsetH
  26.     set vLoc to V - OffsetV
  27.     constrainSprite(hLoc, vLoc, constrainRect)
  28.     set the loc of sprite getaProp(OBj, #SpriteNum) to the result
  29.     set arect to rect(the locH of sprite getaProp(OBj, #SpriteNum) + 17, the locV of sprite getaProp(OBj, #SpriteNum) + 33, the locH of Anchor, the locV of Anchor)
  30.     CableUpdate(cableref, arect)
  31.     CursorandUpdate()
  32.     CheckAmbientSound()
  33.     set H to the mouseH
  34.     set V to the mouseV
  35.   end repeat
  36.   cursor(getaProp(gCursorlist, #Hand))
  37.   if not voidp(getaProp(getaProp(OBj, #sound), #UP)) then
  38.     playSound(getaProp(getaProp(OBj, #sound), #UP), #keyframeCast, #NOW)
  39.   end if
  40.   if not voidp(getaProp(getaProp(OBj, #Action), #UP)) then
  41.     do(getaProp(getaProp(OBj, #Action), #UP))
  42.   end if
  43.   DynamicLOCRECT(#DefibCable1)
  44.   DynamicLOCRECT(#DefibCable2)
  45. end
  46.  
  47. on doSyringe
  48. end
  49.  
  50. on GrabPullPlunger OBJref
  51.   set H to the mouseH
  52.   set V to the mouseV
  53.   set OBj to getaProp(gObjects, OBJref)
  54.   set ObjH to the locH of sprite getaProp(OBj, #SpriteNum)
  55.   set ObjV to the locV of sprite getaProp(OBj, #SpriteNum)
  56.   set SpriteList to []
  57.   set ObjrefList to []
  58.   repeat with C in getaProp(OBj, #Children)
  59.     set O to getaProp(gObjects, C)
  60.     add(ObjrefList, C)
  61.     add(SpriteList, [#SpriteNum: getaProp(O, #SpriteNum), #OffsetH: ObjH - the locH of sprite getaProp(O, #SpriteNum), #OffsetV: ObjV - the locV of sprite getaProp(O, #SpriteNum)])
  62.   end repeat
  63.   set OBJcount to count(ObjrefList)
  64.   if not voidp(getaProp(getaProp(OBj, #sound), #down)) then
  65.     playSound(getaProp(getaProp(OBj, #sound), #down), #keyframeCast, #NOW)
  66.   end if
  67.   updateStage()
  68.   set contrainRect to getConstrainRect(OBJref)
  69.   set OffsetH to H - ObjH
  70.   set OffsetV to V - ObjV
  71.   repeat while the mouseDown
  72.     set hLoc to H - OffsetH
  73.     set vLoc to V - OffsetV
  74.     set newLoc to constrainSprite(hLoc, vLoc, contrainRect)
  75.     set the loc of sprite getaProp(OBj, #SpriteNum) to newLoc
  76.     repeat with Snum in SpriteList
  77.       set the loc of sprite getaProp(Snum, #SpriteNum) to newLoc - point(getaProp(Snum, #OffsetH), getaProp(Snum, #OffsetV))
  78.     end repeat
  79.     CursorandUpdate()
  80.     set H to the mouseH
  81.     set V to the mouseV
  82.   end repeat
  83.   if not voidp(getaProp(getaProp(OBj, #sound), #UP)) then
  84.     playSound(getaProp(getaProp(OBj, #sound), #UP), #keyframeCast, #NOW)
  85.   end if
  86.   updateStage()
  87.   cursor(getaProp(gCursorlist, #Hand))
  88.   DynamicLOCRECT(#syringe)
  89.   DynamicLOCRECT(#plunger)
  90.   updateStage()
  91. end
  92.  
  93. on getConstrainRect OBJref
  94.   set OBj to getaProp(gObjects, OBJref)
  95.   set halfWidth to the width of cast the castNum of sprite getaProp(OBj, #SpriteNum) / 2
  96.   set halfHeight to the height of cast the castNum of sprite getaProp(OBj, #SpriteNum) / 2
  97.   set constrainRect to rect(the left of sprite 1 + halfWidth, the top of sprite 1 + halfHeight, the right of sprite 1 - halfWidth, the bottom of sprite 1 - halfHeight)
  98.   return constrainRect
  99. end
  100.  
  101. on DoPlungerReset
  102. end
  103.  
  104. on DoPlunger
  105.   playSound("H12inj.aif", #keyframeCast, #NOW)
  106.   set plungeSprite to getaProp(getaProp(gObjects, #plunger), #SpriteNum)
  107.   set plungeLocH to the locH of sprite plungeSprite
  108.   repeat with X = 1 to 7
  109.     set the locH of sprite plungeSprite to plungeLocH - (X * 3)
  110.     CallAnimEngine()
  111.     updateStage()
  112.   end repeat
  113.   set curState to getaProp(getaProp(gObjects, #heartAnimPar), #State)
  114.   repeat with X = 6 down to 0
  115.     set the locH of sprite plungeSprite to plungeLocH - (X * 3)
  116.     CallAnimEngine()
  117.     updateStage()
  118.   end repeat
  119.   if curState = #threeclogs then
  120.     set targetRect to rect(269, 69, 276, 77)
  121.     checkShotRect(#twoclogs, targetRect)
  122.   else
  123.     if curState = #twoclogs then
  124.       set targetRect to rect(264, 125, 271, 133)
  125.       checkShotRect(#oneclog, targetRect)
  126.     else
  127.       if curState = #oneclog then
  128.         set targetRect to rect(259, 183, 266, 189)
  129.         checkShotRect(#noclogs, targetRect)
  130.         if the result = 1 then
  131.           setaProp(getaProp(gStates, #Conditions), #Heart, #true)
  132.           PDARelease("J04m27j.mov")
  133.         end if
  134.       else
  135.       end if
  136.     end if
  137.   end if
  138. end
  139.  
  140. on checkShotRect OBJref, targetRect
  141.   set needleLoc to the loc of sprite getaProp(getaProp(gObjects, #syringe), #SpriteNum)
  142.   if inside(needleLoc, targetRect) then
  143.     set Mobj to getaProp(gObjects, #heartAnimPar)
  144.     DelObjects(getaProp(getaProp(Mobj, #SpecialChild), getaProp(Mobj, #State)))
  145.     setaProp(Mobj, #State, OBJref)
  146.     AddObjects(getaProp(getaProp(Mobj, #SpecialChild), getaProp(Mobj, #State)))
  147.     return 1
  148.   else
  149.     return 0
  150.   end if
  151. end
  152.  
  153. on DoDefibZap
  154.   set paddle1Loc to the loc of sprite getaProp(getaProp(gObjects, #DefibPaddle1), #SpriteNum)
  155.   set paddle2Loc to the loc of sprite getaProp(getaProp(gObjects, #DefibPaddle2), #SpriteNum)
  156.   if inside(paddle1Loc, rect(145, 71, 180, 106)) and inside(paddle2Loc, rect(241, 71, 277, 106)) then
  157.     setaProp(getaProp(gStates, #Conditions), #Defibrillate, #true)
  158.     DoStableGO()
  159.   end if
  160. end
  161.  
  162. on DoDefibPower
  163.   set PowerObj to getaProp(gObjects, #DefibPower)
  164.   set curState to getaProp(PowerObj, #State)
  165.   set DefibObj to getaProp(gObjects, #DefibScreen)
  166.   if curState = #open then
  167.     if getaProp(getaProp(gStates, #Conditions), #Defibrillate) <> #true then
  168.       DoDefibGO()
  169.     else
  170.       DoHeartGO()
  171.     end if
  172.   else
  173.     DoTurnDefibOFF()
  174.   end if
  175. end
  176.  
  177. on DoStableGO
  178.   set Mobj to getaProp(gObjects, #fibFdBckPar)
  179.   DelObjects(getaProp(getaProp(Mobj, #SpecialChild), getaProp(Mobj, #State)))
  180.   MakeDynamic(#fibFdBckPar, #State, #stable)
  181.   AddObjects(getaProp(getaProp(Mobj, #SpecialChild), getaProp(Mobj, #State)))
  182.   stopsound("H12ekg1.aif")
  183.   playSound("H12ekg2.aif", #cast)
  184. end
  185.  
  186. on doTextFldFormat
  187.   put " " into field "PaPinText"
  188.   set the textFont of field "PaPinText" to "Monaco"
  189.   set the textSize of field "PaPinText" to 14
  190.   set the foreColor of field "PaPinText" to getIndex([8: 251, 16: 16, 32: 128])
  191.   set the textStyle of field "PaPinText" to "bold"
  192.   put EMPTY into field "PaPinText"
  193. end
  194.  
  195. on PaSelect NUM
  196.   MakeDynamic(#PaPatients, #whichPatient, NUM)
  197. end
  198.  
  199. on doBeep
  200.   playSound("H09hi.aif", #keyframeCast, #NOW)
  201. end
  202.  
  203. on PatientMenu OBJref
  204.   findPatient()
  205.   set OBj to getaProp(gObjects, OBJref)
  206.   repeat while the mouseDown
  207.     do(getaProp(getaProp(OBj, #Action), #WhileDown))
  208.     CursorandUpdate()
  209.   end repeat
  210.   if getaProp(OBj, #currect) <> #empty then
  211.     set the castNum of sprite getaProp(OBj, #SpriteNum) to getaProp(getaProp(getaProp(OBj, #cast), getaProp(OBj, #currect)), #UP)
  212.     set the loc of sprite getaProp(OBj, #SpriteNum) to getaProp(getaProp(getaProp(OBj, #PopMenu), getaProp(OBj, #currect)), #loc)
  213.     updateStage()
  214.     setaProp(OBj, #DisplayState, getaProp(OBj, #currect))
  215.     if not voidp(getaProp(getAt(getaProp(OBj, #PopMenu), getaProp(OBj, #currect)), #Action)) then
  216.       do(getaProp(getAt(getaProp(OBj, #PopMenu), getaProp(OBj, #currect)), #Action))
  217.     end if
  218.   end if
  219.   playSound("H09hi.aif", #keyframeCast, #NOW)
  220. end
  221.  
  222. on findPatient
  223.   set H to the mouseH
  224.   set V to the mouseV
  225.   set OBj to getaProp(gObjects, #PaPatients)
  226.   set aRectNum to InUnvRect(getaProp(OBj, #PopMenu), H, V)
  227.   if aRectNum <> #empty then
  228.     set the castNum of sprite getaProp(OBj, #SpriteNum) to getaProp(getaProp(getaProp(OBj, #cast), aRectNum), #down)
  229.     set the loc of sprite getaProp(OBj, #SpriteNum) to getaProp(getaProp(getaProp(OBj, #PopMenu), aRectNum), #loc)
  230.   else
  231.     set the castNum of sprite getaProp(OBj, #SpriteNum) to cNullCast
  232.     set the loc of sprite getaProp(OBj, #SpriteNum) to point(-2000, -2000)
  233.   end if
  234.   setaProp(OBj, #currect, aRectNum)
  235. end
  236.  
  237. on TurnPaMonitorON
  238.   set Mobj to getaProp(gObjects, #PaMonitor)
  239.   playSound("H09monOn.aif", #keyframeCast)
  240.   repeat with Casnum in getaProp(getaProp(Mobj, #cast), #on)
  241.     set the castNum of sprite getaProp(Mobj, #SpriteNum) to Casnum
  242.     updateStage()
  243.   end repeat
  244.   DoPaPatientGO()
  245. end
  246.  
  247. on DoSetToOFF
  248.   set Mobj to getaProp(gObjects, #PaMonitor)
  249.   DelObjects(getaProp(getaProp(Mobj, #SpecialChild), getaProp(Mobj, #State)))
  250.   MakeDynamic(#PaMonitor, #State, #off)
  251.   MakeDynamic(#PaMonitor, #DisplayState, #INIT)
  252. end
  253.  
  254. on DoPaPatientGO
  255.   set Mobj to getaProp(gObjects, #PaMonitor)
  256.   DelObjects(getaProp(getaProp(Mobj, #SpecialChild), getaProp(Mobj, #State)))
  257.   MakeDynamic(#PaMonitor, #State, #Patients)
  258.   MakeDynamic(#PaMonitor, #DisplayState, #Patients)
  259.   AddObjects(getaProp(getaProp(Mobj, #SpecialChild), getaProp(Mobj, #State)))
  260.   set the castNum of sprite getaProp(Mobj, #SpriteNum) to getaProp(getaProp(Mobj, #cast), #Patients)
  261.   MakeDynamic(#PaPatients, #whichPatient, 0)
  262. end
  263.  
  264. on DoPaPINGO
  265.   if getaProp(getaProp(gObjects, #PaPatients), #whichPatient) = 0 then
  266.     exit
  267.   end if
  268.   set Mobj to getaProp(gObjects, #PaMonitor)
  269.   DelObjects(getaProp(getaProp(Mobj, #SpecialChild), getaProp(Mobj, #State)))
  270.   MakeDynamic(#PaMonitor, #State, #PIN)
  271.   MakeDynamic(#PaMonitor, #DisplayState, #PIN)
  272.   AddObjects(getaProp(getaProp(Mobj, #SpecialChild), getaProp(Mobj, #State)))
  273.   set the castNum of sprite getaProp(Mobj, #SpriteNum) to getaProp(getaProp(Mobj, #cast), #PIN)
  274. end
  275.  
  276. on DoPaStatusGO
  277.   set Mobj to getaProp(gObjects, #PaMonitor)
  278.   DelObjects(getaProp(getaProp(Mobj, #SpecialChild), getaProp(Mobj, #State)))
  279.   MakeDynamic(#PaMonitor, #State, #Status)
  280.   MakeDynamic(#PaMonitor, #DisplayState, #Status)
  281.   AddObjects(getaProp(getaProp(Mobj, #SpecialChild), getaProp(Mobj, #State)))
  282.   set the castNum of sprite getaProp(Mobj, #SpriteNum) to getaProp(getaProp(Mobj, #cast), #Status)
  283. end
  284.  
  285. on doNursevid
  286.   set OBj to getaProp(gObjects, #NurseVid)
  287.   set clickCount to getaProp(OBj, #clickCount) + 1
  288.   MakeDynamic(#NurseVid, #clickCount, clickCount)
  289.   pickNurse(clickCount)
  290.   set the movieRate of sprite sQTCharSprite to 0
  291.   set the movieTime of sprite sQTCharSprite to 0
  292.   set the movieRate of sprite sQTCharSprite to 1
  293. end
  294.  
  295. on doPeoplevid
  296.   set OBj to getaProp(gObjects, #Peoplevid)
  297.   set the movieTime of sprite getaProp(OBj, #SpriteNum) to 0
  298.   set the movieRate of sprite getaProp(OBj, #SpriteNum) to 1
  299. end
  300.  
  301. on DoGetSyringe
  302.   if getaProp(getaProp(gObjects, #TubeObj), #Aquired) = #true then
  303.     playSound("Click.aif", #keyframeCast, #NOW)
  304.     updateStage()
  305.     MakeDynamic(#TubeObj, #Aquired, #USED)
  306.     MakeDynamic(#syrnObj, #Aquired, #true)
  307.     set OBj to getaProp(gObjects, #GetSyringe)
  308.     MakeDynamic(#GetSyringe, #State, #gone)
  309.     MakeDynamic(#GetSyringe, #DisplayState, #gone)
  310.     MakeDynamic(#GetSyringe, #Hotrect, [NULLrect])
  311.     set the castNum of sprite getaProp(OBj, #SpriteNum) to getaProp(getaProp(OBj, #cast), #gone)
  312.     set hotrectnum to integer(getaProp(OBj, #SpriteNum) & "01")
  313.     setaProp(getaProp(gHotRects, hotrectnum), #rect, NULLrect)
  314.     AddObjects([#syrnObj])
  315.   end if
  316. end
  317.  
  318. on doPatientName
  319. end
  320.  
  321. on DoPaEnterPin
  322. end
  323.  
  324. on doPinEntry
  325. end
  326.  
  327. on doPower
  328. end
  329.  
  330. on doLeftElectrode
  331. end
  332.  
  333. on doRightElectrode
  334. end
  335.  
  336. on doApplyShock
  337. end
  338.  
  339. on doMagnify
  340. end
  341.  
  342. on doShrink
  343. end
  344.  
  345. on goToH05
  346. end
  347.